<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box {
      display: grid;
      /* 绝对单位 */
      /* grid-template-columns: 100px 100px 100px;
      grid-template-rows: 100px; */

      /* 百分比 */
      /* grid-template-columns: 33.333% 33.333% 33.333%;
      grid-template-rows: 100px; */

      /* repeat(重复的次数, 重复的值) */
      /* grid-template-columns: repeat(3, 100px);
      grid-template-rows: repeat(1, 100px); */

      /* repeat(重复的次数, 重复的模式) */
      /* grid-template-columns: repeat(3, 100px 120px);
      grid-template-rows: repeat(2, 50px 100px); */

      /* auto-fill 关键字, 自动填充, 实现N个相同的正方形填满容器 */
      /* height: 500px;
      grid-template-columns: repeat(auto-fill, 100px);
      grid-template-rows: repeat(auto-fill, 100px); */

      /* fr 关键字, 比例关系, 实现双飞翼布局 */
      /* grid-template-columns: 200px 1fr;
      grid-template-rows: 100px; */

      /* minmax(最小值, 最大值) */
      /* grid-template-columns: 1fr 1fr minmax(100px, 1fr);
      grid-template-rows: 100px; */

      /* auto 关键字 表示由浏览器自己决定长度。圣杯布局 */
      /* grid-template-columns: 100px auto 100px;
      grid-template-rows: 100px; */

      /* 网格线的名称 */
      /* 上面代码指定网格布局为3行 x 3列，因此有4根垂直网格线和4根水平网格线。方括号里面依次是这八根线的名字。网格布局允许同一根线有多个名字，比如[fifth-line row-5]。 */
      grid-template-columns: [c1] 100px [c2] 100px [c3] auto [c4 列4];
      grid-template-rows: [r1] 100px [r2] 100px [r3] auto [r4];
    }
    
    .box > .item:nth-of-type(1) {
      background-color: aqua;
    }
    .box > .item:nth-of-type(2) {
      background-color: salmon;
    }
    .box > .item:nth-of-type(6) {
      background-color: brown;
    }
    .box > .item:nth-of-type(9) {
      background-color: blueviolet;
    }
    .box > .item:nth-of-type(16) {
      background-color:tomato;
    }
    .box > .item:nth-of-type(19) {
      background-color:yellowgreen;
    }
  </style>
</head>

<body>
  <div class="box">
    <div class="item">
      <p>1</p>
    </div>
    <div class="item">
      <p>2</p>
    </div>
    <div class="item">
      <p>3</p>
    </div>
    <div class="item">
      <p>4</p>
    </div>
    <div class="item">
      <p>5</p>
    </div>
    <div class="item">
      <p>6</p>
    </div>
    <div class="item">
      <p>7</p>
    </div>
    <div class="item">
      <p>8</p>
    </div>
    <div class="item">
      <p>9</p>
    </div>
    <div class="item">
      <p>10</p>
    </div>
    <div class="item">
      <p>11</p>
    </div>
    <div class="item">
      <p>12</p>
    </div>
    <div class="item">
      <p>13</p>
    </div>
    <div class="item">
      <p>14</p>
    </div>
    <div class="item">
      <p>15</p>
    </div>
    <div class="item">
      <p>16</p>
    </div>
    <div class="item">
      <p>17</p>
    </div>
    <div class="item">
      <p>18</p>
    </div>
    <div class="item">
      <p>19</p>
    </div>
    <div class="item">
      <p>20</p>
    </div>
    <div class="item">
      <p>21</p>
    </div>
    <div class="item">
      <p>22</p>
    </div>
    <div class="item">
      <p>23</p>
    </div>
    <div class="item">
      <p>24</p>
    </div>
  </div>
</body>

</html>